<template>
	<view>
		<!-- banner -->
		<view class="allbanner" style="position: relative;">
			<view class="bannercenter flexcolumn">
				<view class="bannerimgtext">
					<image src="@/static/image/system/f7xn.png" mode="" class=""></image>
				</view>
				<view class="bannertext3 margin_top">法律文书</view>
			</view>
			<image :src="topimg" mode=""></image>
		</view>
		<!-- 搜索 -->
		<view class="ffffff mainpadding">
			<view class="sousuobox">
				<view class="flexbetween">
					<input type="text" placeholder="请输入输入关键词" @confirm="init()" v-model="keywords" confirm-type="search">
					<view class="flexright" @click="init">
						<view class="strongtext margin_right1">搜索</view>
						<u-icon name="search" color="#c89d3b" size="20"></u-icon>
					</view>
				</view>
			</view>
			<view class="flexleft margin_top">
				<u-radio-group v-model="is_vip" placement="row" circle>
					<u-radio activeColor="#c89d3b" :customStyle="{marginRight: '30rpx'}" label="会员" name="2"></u-radio>
					<u-radio activeColor="#c89d3b" label="非会员" name="1"></u-radio>
				</u-radio-group>
			</view>
			<view class="nostrongtext margin_top">会员每天可下载100篇</view>
			<!-- word内容 -->
			<view class="mainpadding2 block" v-if="list.total">
				<view class="flexleft flex_wrap">
					<view class="sanshi flexcenter margin_top " v-for=" item in list.data" :key="item.id" @click="tzxq(item)">
						<view class="" style="width: 95%;">
							<view class="yinybox">
								<view class="flexleft">
									<view class="word margin_right1"></view>
									<view class="nostrongtext yhxk" style="width: 120rpx;">{{item.title}}</view>
								</view>
								<view class="wodshilitu">
									<image :src="item.image_text" mode=""></image>
									<view class="vipimage" v-if="item.is_vip==2"></view>
								</view>
							</view>
							<view class="ffffff " style="padding: 6rpx 10rpx;">
								<view class="nostrongtext yhxk">{{item.title}}</view>
							</view>
						</view>
					</view>
					
				</view>
			</view>
		</view>
		<huiyuansjpop :messageInfo="{hysjShow:hysjShow}" @hysjclose="hysjShow=false"></huiyuansjpop>
	</view>
</template>

<script>
	const httpRequest = require("@/common/httpRequest.js")
	export default {
		data() {
			return {
				topimg:"",
				is_vip: "2",
				page: 1,
				limit: 12,
				keywords:"",
				list: {
					data: [],
				},
				hysjShow:false,
				userinfo:{},
			}
		},
		watch:{
			is_vip(newval){
				this.init()
			}
		},
		onLoad() {
			this.init()
			this.getbanner()
			this.getuserinfo()
		},
		methods: {
			getuserinfo(){
				httpRequest.request('/api/user/index', 'GET', {}, false, false, true).then(res => {
					this.userinfo = res.data
				})
			},
			getbanner() {
				httpRequest.request('/api/index/getAdvertiseList', 'POST', {
					advertise_position_id: 16,
					is_more: 2
				}, false, false, true).then(res => {
					this.topimg = res.data.image_text
				})
			},
			init(isPage, page) {
				let _this = this;
				httpRequest.request("/api/index/flwsIndex", 'GET', {
					page: page || 1,
					limit: _this.limit,
					keywords: this.keywords,
					is_vip: this.is_vip,
				}, false, false, true).then(res => {
					if (res.code == 1) {
						let resList = res.data;
						let dataList = _this.list;
						if (isPage == true) {
							_this.list.data = dataList.data.concat(resList.data);
						} else {
							_this.list = resList
							_this.list.data = resList.data;
						}
						this.pageshow = true
					}
					uni.hideLoading()
				}).catch(err => {
					uni.hideLoading()
					httpRequest.toast(err.msg);
				})
			},
			onReachBottom() {
				let _this = this;
				let list = _this.list;
				let page = _this.page;
				if (list.last_page <= page) {
					return false;
				}
				page++;
				_this.page = page;
				_this.init(true, page);
			},
			close() {
				this.show = false
			},
			// 查看详情
			tzxq(item) {
				if(this.userinfo.level==0 && item.is_vip==2){
					this.hysjShow = true
					return false
				}
				uni.navigateTo({
					url:'/pages/index/falvwensxq?id='+item.id
				})
			}
		}
	}
</script>

<style lang="scss" scoped>

	.weizhi {
		position: absolute;
		bottom: 40rpx;
		right: 40rpx;
	}
	.vipimage{
		position: absolute;
		width: 50rpx;
		height: 50rpx;
		background-image: url("@/static/image/system/renzls.png");
		background-size: 100% 100%;
		bottom: 15rpx;
		right: 15rpx;
	}

	.wodshilitu {
		margin: 20rpx auto 0;
		width: 160rpx;
		height: 224rpx;
		position: relative;
		image {
			width: 100%;
			height: 100%;
		}
	}

	.yhxk {
		overflow: hidden;
		text-overflow: ellipsis;
		white-space: nowrap;
	}

	.yinybox {
		padding: 20rpx;
		background-color: #dedede;
	}

	.sanshi {
		width: 33.33%;
	}

	.block {
		background-color: #f6f8fa;
	}

	.huisebox {
		background-color: #37474F;
		color: #fff;
		padding: 10rpx 30rpx;
	}

	.weixuanzong {
		width: 40rpx;
		height: 40rpx;
		border-radius: 50%;

		image {
			border-radius: 50%;
			width: 100%;
			height: 100%;
		}
	}

	.yixuanzong {
		width: 40rpx;
		height: 40rpx;
		border-radius: 50%;

		image {
			border-radius: 50%;
			width: 100%;
			height: 100%;
		}
	}

	.wqeizhi {
		position: absolute;
		bottom: 84rpx;
		left: 36%;
	}
</style>